//
//  CellForIconDetail.m
//  MY Project For Sport
//
//  Created by dllo on 16/1/30.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForIconDetail.h"
#import "ModelForIconDetail.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <DKNightVersion.h>
#import "UIColor+Wonderful.h"

#define WEIGHT self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667



@interface CellForIconDetail ()

@property (nonatomic, retain) UILabel *team1;
@property (nonatomic, retain) UILabel *team2;
@property (nonatomic, retain) UILabel *score1;
@property (nonatomic, retain) UILabel *score2;
@property (nonatomic, retain) UILabel *leagueType;
@property (nonatomic, retain) UILabel *round;
@property (nonatomic, retain) UIImageView *team1View;
@property (nonatomic, retain) UIImageView *team2View;
@property (nonatomic ,retain) UIView *myView;


@end

@implementation CellForIconDetail

- (void)dealloc {
    [_team1 release];
    [_team2 release];
    [_score1 release];
    [_score2 release];
    [_leagueType release];
    [_round release];
    [_team1View release];
    [_team2View release];
    [_myView release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor linenColor], [UIColor grayColor]);
        
        [self createSubview];
        
        
    }

    return self;

}


-(void)createSubview {

    self.myView = [[UIView alloc] init];
    [self.contentView addSubview:self.myView];
    self.myView.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], Wonderful_GrayColor5);
    [_myView release];
    
   // self.contentView.backgroundColor = [UIColor whiteColor];
    self.leagueType = [[UILabel alloc] init];
    self.leagueType.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.leagueType];
    [_leagueType release];
    
    self.round = [[UILabel alloc] init];
    self.round.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.round];
    [_round release];
    
    self.team1 = [[UILabel alloc] init];
    [self.contentView addSubview:self.team1];
    [_team1 release];
    
    
    self.team2 = [[UILabel alloc] init];
    [self.contentView addSubview:self.team2];
    [_team2 release];
    
    self.score1 = [[UILabel alloc] init];
    self.score1.font = [UIFont systemFontOfSize:20];
    [self.contentView addSubview:self.score1];
    [_score1 release];
    
    
    self.score2 = [[UILabel alloc] init];
    self.score2.font = [UIFont systemFontOfSize:20];
    [self.contentView addSubview:self.score2];
    [_score2 release];
    
    self.team1View = [[UIImageView alloc] init];
    [self.contentView addSubview:self.team1View];
    [_team1View release];
    
    self.team2View = [[UIImageView alloc] init];
    [self.contentView addSubview:self.team2View];
    [_team2View release];
    

}

-(void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.myView.frame = CGRectMake(2 * WEIGHTT, 5 * HEIGHTT, WEIGHT, HEIGHT - 10 * HEIGHTT);
    
    //  NSLog(@"%f", self.contentView.frame.size.height);
    self.leagueType.frame = CGRectMake(10 * WEIGHTT, 10 * HEIGHTT, WEIGHT / 9.4, HEIGHT / 8.4);
    self.round.frame = CGRectMake(WEIGHT / 9.4 + 15 * WEIGHTT, 10 * HEIGHTT, WEIGHT / 9.4, HEIGHT / 8.4);
    //self.leagueType.textColor = [UIColor grayColor];
    self.leagueType.dk_textColorPicker = DKColorWithColors([UIColor grayColor], [UIColor whiteColor]);
   // self.round.textColor = [UIColor grayColor];
    self.round.dk_textColorPicker = DKColorWithColors([UIColor grayColor], [UIColor whiteColor]);
    
    
    self.team1View.frame = CGRectMake(10 * WEIGHTT,  HEIGHT / 8.4 + 20 * HEIGHTT, HEIGHT / 3.6, HEIGHT / 3.6);
    self.team1View.layer.cornerRadius = HEIGHT / 7.2;
    self.team1View.layer.masksToBounds = YES;
    
    self.team2View.frame = CGRectMake(10 * WEIGHTT, HEIGHT / 8.4 + HEIGHT / 3.6 + 30 * HEIGHTT, HEIGHT / 3.6, HEIGHT / 3.6);
    self.team2View.layer.cornerRadius = HEIGHT / 7.2;
    self.team2View.layer.masksToBounds = YES;
    
    
    self.team1.frame = CGRectMake(WEIGHT / 3.9, HEIGHT / 4.2, WEIGHT / 3.1, HEIGHT / 3.34);
    self.team1.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    self.team2.frame = CGRectMake(WEIGHT / 3.9, HEIGHT / 1.67, WEIGHT / 3.1, HEIGHT / 3.34);
    self.team2.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    self.score1.frame = CGRectMake(WEIGHT / 1.3, HEIGHT / 4.2, HEIGHT / 3.34, HEIGHT / 3.34);
    self.score1.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    self.score2.frame = CGRectMake(WEIGHT / 1.3, HEIGHT / 1.67, HEIGHT / 3.34, HEIGHT / 3.34);
    self.score2.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
}

-(void)passModelForHot:(ModelForIconDetail *)hotModel {
    
    self.leagueType.text = hotModel.LeagueType_cn;
    self.round.text = hotModel.Round_cn;
    self.team1.text = hotModel.Team1;
    self.team2.text = hotModel.Team2;
    self.score1.text = hotModel.Score1;
    self.score2.text = hotModel.Score2;
    [self.team1View sd_setImageWithURL:[NSURL URLWithString:hotModel.Flag1]];
    [self.team2View sd_setImageWithURL:[NSURL URLWithString:hotModel.Flag2]];
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
